package com.lianxi

/**
  * Created by adengdeng on 2017/8/7 
  */
object Lx3 {

  def main(args: Array[String]): Unit = {

    val a = Array(1, 2, 3, 4, 5)
    val b = for (i <- 0 until a.length) yield {
      if (i< a.length -1 & i % 2  == 0){
        val tmp = a(i)
        a(i) = a(i+1)
        a(i+1) = tmp
      }
      a(i)
    }

    println(a.mkString(" "))
    println(b)
  }
}
